<template>
  <div>
    <el-button size="mini" type="primary" :icon="isView ? 'el-icon-more' : 'el-icon-edit'" @click="to" />
    <eForm ref="form" :sup-this="supThis" :is-add="false" :is-view="isView" />
  </div>
</template>
<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    data: {
      type: Object,
      required: true
    },
    supThis: {
      type: Object,
      required: true
    },
    isView: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    to() {
      const _this = this.$refs.form
      var objName = []
      this.data.objName.split(',').forEach(function(data, index) { objName.push(Number(data)) })
      var toolId = []
      if (this.data.toolName) {
        this.data.toolName.split(',').forEach(function(data, index) { toolId.push(Number(data)) })
      }
      _this.getInpectionTools()
      _this.queryAllEqpt()
      _this.queryAllTemplate()
      _this.tServiceproviderInfoAll()
      _this.form = {
        id: this.data.id,
        planName: this.data.planName,
        objName: this.data.toolName,
        objId: objName,
        toolName: this.data.toolName,
        toolId: toolId,
        templateId: this.data.templateId,
        templateName: this.data.templateName,
        planDesc: this.data.planDesc,
        periodId: this.data.periodId,
        periodName: this.data.periodName,
        inspectorId: this.data.inspectorId,
        inspectorName: this.data.inspectorName,
        vehTypeId: this.data.vehTypeId, // useless
        vehTypeName: this.data.vehTypeName, // useless
        startTime: this.data.startTime,
        endTime: this.data.endTime,
        state: String(this.data.state),
        inputOperator: this.data.inputOperator,
        inputTime: this.data.inputTime,
        notes: this.data.notes
      }
      console.log(this.data)
      _this.dialog = true
    }
  }
}
</script>

<style scoped>
  div{
    display: inline-block;
    margin-right: 3px;
  }
</style>
